package com.nsl.my_youlai.bbu_return.convert.enums;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.nsl.my_youlai.bbu_return.enums.GenerationTypeEnum;
import com.nsl.my_youlai.common.base.IBaseEnum;
import com.nsl.my_youlai.mystar.enums.NslEnumBaseI;
import lombok.extern.slf4j.Slf4j;


@Slf4j
public class GenerationTypeEnumConvert implements Converter<GenerationTypeEnum> {
    @Override
    public Class<GenerationTypeEnum> supportJavaTypeKey() {
        return GenerationTypeEnum.class;
    }
 
    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }
 


    @Override
    public GenerationTypeEnum convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        //log.info("in convertToJavaData");
        return NslEnumBaseI.getEnumByLabel(cellData.getStringValue(),GenerationTypeEnum.class);


    }

 
//导出时转换
    @Override
    public WriteCellData<GenerationTypeEnum> convertToExcelData(GenerationTypeEnum value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {

        WriteCellData<GenerationTypeEnum> writeCellData=new WriteCellData<>(CellDataTypeEnum.STRING,value.getLabel());
        return writeCellData;
    }
}